a, b = map(int, input().split())
c, d = map(int, input().split())

t1 = a * 60 + b
t2 = c * 60 + d

print(t2 - t1)

